import 'package:flutter/material.dart';
import 'package:flutter_demo/tmac/util/SystemUtil.dart';
import 'package:flutter_demo/tmac/widget/AllDrawableTextWidget2.dart';
import 'package:flutter_demo/tmac/widget/DirectionEnum.dart';
import 'package:flutter_demo/tmac/widget/drawableTextWidget.dart';
import 'package:flutter_demo/wzw/mybutton.dart';
import 'package:fluttertoast/fluttertoast.dart';

class SkinChangePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new SkinChangeState();
  }
}

class SkinChangeState extends State<SkinChangePage> {
  Color _themeColor = Colors.blue;
  @override
  void initState() {
    super.initState();
    SystemUtil.statusColorBar(color: _themeColor);
  }

  @override
  Widget build(BuildContext context) {
    ThemeData themeData = Theme.of(context);

    return Theme(
        data: ThemeData(
            primarySwatch: _themeColor,
            iconTheme: IconThemeData(color: _themeColor)),
        child: Scaffold(
          appBar: AppBar(
            title: Text(
              "换肤",
              style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
            ),
            centerTitle: true,
          ),
          floatingActionButton: FloatingActionButton(child:Icon(Icons.palette),onPressed: () {
            setState(() {
              _themeColor =
                  _themeColor == Colors.blue ? Colors.red : Colors.blue;
              SystemUtil.statusColorBar(color: _themeColor);
            });
          }),
          body: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                //第一行Icon使用主题中的iconTheme
                Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(Icons.favorite),
                      Icon(Icons.airport_shuttle),
                      Text("颜色跟随主题")
                    ]),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    AllDrawableTextWidget2(
                      paddingLeft: 10,
                      paddingRight: 10,
                      paddingTop: 20,
                      paddingBottom: 20,
                      title: Text("自定义控件"),
                      iconLeft: Icon(
                        Icons.face,
                        size: 20,
                      ),
                      iconRight: Icon(
                        Icons.face,
                        size: 20,
                      ),
                      iconTop: Icon(
                        Icons.face,
                        size: 20,
                      ),
                      iconBottom: Image.asset(
                        'images/icon_splash.png',
                        width: 50,
                        filterQuality: FilterQuality.high,
                        height: 50,)
                    )
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    DrawableTextWidget(
                      title: Text("自定义控件"),
                      icon: Icon(
                        Icons.account_balance,
                        size: 25,
                      ),
                      direction: Direction.Left,
                    ),
                    Padding(padding: EdgeInsets.only(right: 20)),
                    MyButton(
                        label: Text("myButton"),
                        icon: Icon(
                          Icons.face,
                          size: 30,
                        ),
                        pressed: () {
                          Fluttertoast.showToast(msg: "点击");
                        }),
                  ],
                ),

                Theme(
                  data: themeData.copyWith(
                      iconTheme:
                          themeData.iconTheme.copyWith(color: Colors.black)),
                  child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Icon(Icons.favorite),
                        Icon(Icons.airport_shuttle),
                        Text("  颜色固定黑色")
                      ]),
                )
              ],
            ),
          ),
        ));
  }
}
